const { saveAvatarInfo } = require('../service/file.service')
class FileController {
  async saveAvatarInfo(ctx, next) {
    console.log(ctx.req.file)
    // 1.获取文件信息
    const { filename, mimetype, size } = ctx.req.file
    const { name, id } = ctx.user
    // 2.将文件信息保存至数据库
    const results = await saveAvatarInfo(filename, mimetype, size, id)
    console.log(results)
    if (!results[1]) {
      ctx.body = '文件上传成功'
    } else {
      ctx.body = '文件上传失败'
    }
  }
}
module.exports = new FileController()
